package com.ct.entity.po;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import lombok.Builder;
import org.springframework.format.annotation.DateTimeFormat;

import com.ct.entity.enums.DateTimePatternEnum;
import com.ct.utils.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 出差表
 */
@Builder
public class Travel implements Serializable {

    /**
     * 出差编号
     */
    private Integer travelId;

    /**
     * 出差原因
     */
    private String travelReason;

    /**
     * 出差详情
     */
    private String travelDetail;

    /**
     * 申请日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date applyDate;

    /**
     * 开始日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date startDate;

    /**
     * 结束日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endDate;

    /**
     * 餐饮费
     */
    private BigDecimal foodCost;

    /**
     * 交通费
     */
    private BigDecimal transportCost;

    /**
     * 住宿费
     */
    private BigDecimal hotelCost;

    /**
     * 预算详情
     */
    private String costDetail;

    /**
     * 预支款
     */
    private BigDecimal advancePayment;

    /**
     * 申请人
     */
    private String userId;

    public Travel() {
    }

    public Travel(Integer travelId, String travelReason, String travelDetail, Date applyDate, Date startDate,
            Date endDate, BigDecimal foodCost, BigDecimal transportCost, BigDecimal hotelCost, String costDetail,
            BigDecimal advancePayment, String userId) {
        this.travelId = travelId;
        this.travelReason = travelReason;
        this.travelDetail = travelDetail;
        this.applyDate = applyDate;
        this.startDate = startDate;
        this.endDate = endDate;
        this.foodCost = foodCost;
        this.transportCost = transportCost;
        this.hotelCost = hotelCost;
        this.costDetail = costDetail;
        this.advancePayment = advancePayment;
        this.userId = userId;
    }

    public void setTravelId(Integer travelId) {
        this.travelId = travelId;
    }

    public Integer getTravelId() {
        return this.travelId;
    }

    public void setTravelReason(String travelReason) {
        this.travelReason = travelReason;
    }

    public String getTravelReason() {
        return this.travelReason;
    }

    public void setTravelDetail(String travelDetail) {
        this.travelDetail = travelDetail;
    }

    public String getTravelDetail() {
        return this.travelDetail;
    }

    public void setApplyDate(Date applyDate) {
        this.applyDate = applyDate;
    }

    public Date getApplyDate() {
        return this.applyDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getStartDate() {
        return this.startDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Date getEndDate() {
        return this.endDate;
    }

    public void setFoodCost(BigDecimal foodCost) {
        this.foodCost = foodCost;
    }

    public BigDecimal getFoodCost() {
        return this.foodCost;
    }

    public void setTransportCost(BigDecimal transportCost) {
        this.transportCost = transportCost;
    }

    public BigDecimal getTransportCost() {
        return this.transportCost;
    }

    public void setHotelCost(BigDecimal hotelCost) {
        this.hotelCost = hotelCost;
    }

    public BigDecimal getHotelCost() {
        return this.hotelCost;
    }

    public void setCostDetail(String costDetail) {
        this.costDetail = costDetail;
    }

    public String getCostDetail() {
        return this.costDetail;
    }

    public void setAdvancePayment(BigDecimal advancePayment) {
        this.advancePayment = advancePayment;
    }

    public BigDecimal getAdvancePayment() {
        return this.advancePayment;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserId() {
        return this.userId;
    }

    @Override
    public String toString() {
        return "出差编号:" + (travelId == null ? "空" : travelId) + "，出差原因:" + (travelReason == null ? "空" : travelReason)
                + "，出差详情:" + (travelDetail == null ? "空" : travelDetail) + "，申请日期:"
                + (applyDate == null ? "空" : DateUtil.format(applyDate, DateTimePatternEnum.YYYY_MM_DD.getPattern()))
                + "，开始日期:"
                + (startDate == null ? "空" : DateUtil.format(startDate, DateTimePatternEnum.YYYY_MM_DD.getPattern()))
                + "，结束日期:"
                + (endDate == null ? "空" : DateUtil.format(endDate, DateTimePatternEnum.YYYY_MM_DD.getPattern()))
                + "，餐饮费:" + (foodCost == null ? "空" : foodCost) + "，交通费:"
                + (transportCost == null ? "空" : transportCost) + "，住宿费:" + (hotelCost == null ? "空" : hotelCost)
                + "，预算详情:" + (costDetail == null ? "空" : costDetail) + "，预支款:"
                + (advancePayment == null ? "空" : advancePayment) + "，申请人:" + (userId == null ? "空" : userId);
    }
    public static TravelBuilder builder() {
        return new TravelBuilder();
    }

    public static class TravelBuilder {
        private Integer travelId;
        private String travelReason;
        private String travelDetail;
        private Date applyDate;
        private Date startDate;
        private Date endDate;
        private BigDecimal foodCost;
        private BigDecimal transportCost;
        private BigDecimal hotelCost;
        private String costDetail;
        private BigDecimal advancePayment;
        private String userId;

        TravelBuilder() {
        }

        public TravelBuilder travelId(Integer travelId) {
            this.travelId = travelId;
            return this;
        }

        public TravelBuilder travelReason(String travelReason) {
            this.travelReason = travelReason;
            return this;
        }

        public TravelBuilder travelDetail(String travelDetail) {
            this.travelDetail = travelDetail;
            return this;
        }

        @JsonFormat(
                pattern = "yyyy-MM-dd",
                timezone = "GMT+8"
        )
        public TravelBuilder applyDate(Date applyDate) {
            this.applyDate = applyDate;
            return this;
        }

        @JsonFormat(
                pattern = "yyyy-MM-dd",
                timezone = "GMT+8"
        )
        public TravelBuilder startDate(Date startDate) {
            this.startDate = startDate;
            return this;
        }

        @JsonFormat(
                pattern = "yyyy-MM-dd",
                timezone = "GMT+8"
        )
        public TravelBuilder endDate(Date endDate) {
            this.endDate = endDate;
            return this;
        }

        public TravelBuilder foodCost(BigDecimal foodCost) {
            this.foodCost = foodCost;
            return this;
        }

        public TravelBuilder transportCost(BigDecimal transportCost) {
            this.transportCost = transportCost;
            return this;
        }

        public TravelBuilder hotelCost(BigDecimal hotelCost) {
            this.hotelCost = hotelCost;
            return this;
        }

        public TravelBuilder costDetail(String costDetail) {
            this.costDetail = costDetail;
            return this;
        }

        public TravelBuilder advancePayment(BigDecimal advancePayment) {
            this.advancePayment = advancePayment;
            return this;
        }

        public TravelBuilder userId(String userId) {
            this.userId = userId;
            return this;
        }

        public Travel build() {
            return new Travel(this.travelId, this.travelReason, this.travelDetail, this.applyDate, this.startDate, this.endDate, this.foodCost, this.transportCost, this.hotelCost, this.costDetail, this.advancePayment, this.userId);
        }

        public String toString() {
            return "Travel.TravelBuilder(travelId=" + this.travelId + ", travelReason=" + this.travelReason + ", travelDetail=" + this.travelDetail + ", applyDate=" + this.applyDate + ", startDate=" + this.startDate + ", endDate=" + this.endDate + ", foodCost=" + this.foodCost + ", transportCost=" + this.transportCost + ", hotelCost=" + this.hotelCost + ", costDetail=" + this.costDetail + ", advancePayment=" + this.advancePayment + ", userId=" + this.userId + ")";
        }
    }
}
